/*
package org.example.spring.self.demo;

import org.example.spring.self.demo.service.OrderService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

@ComponentScan("org.example.spring.self.demo")
// 打开aop
@Configuration
// 事务生效 需要 @Configuration 不加这个注解 JdbcTemplate 和 事务管理器 用的就不是同一个 dataSource
// @Configuration AOP @Lazy 动态代理
@EnableTransactionManagement
@EnableAspectJAutoProxy
public class AppConfig {

	@Bean
	public OrderService orderService() {
		System.out.println("bean orderService");
		return new OrderService();
	}

	@Bean
	public JdbcTemplate jdbcTemplate() {
		return new JdbcTemplate(dataSource());
	}

	@Bean
	public PlatformTransactionManager transactionManager() {
		DataSourceTransactionManager transactionManager = new DataSourceTransactionManager();
		transactionManager.setDataSource(dataSource());
		return transactionManager;
	}

	@Bean
	public DataSource dataSource() {
		System.out.println("init dateSource");
		DriverManagerDataSource dataSource = new DriverManagerDataSource();
		dataSource.setUrl("jdbc:mysql://localhost:13306/gin-server?characterEncoding=utf-8&useUnicode=true");
		dataSource.setUsername("root");
		dataSource.setDriverClassName("com.mysql.jdbc.Driver");
		dataSource.setPassword("roottt");
		return dataSource;
	}
}
*/
